<?php 
require_once substr(dirname(__FILE__),0,-1).'sub/init.php';
$str=2021080803;
require_once '../sub/init.php';
$fid=intval($fid);
require_once ZEAI.'m/my_chk_u.php';
require_once ZEAI.'cache/udata.php';
$_ZEAI['cache_str']=ADDTIME;
function jslht_array_sort($arr,$keys,$type='asc'){
 $keysvalue = $new_array = array();
 foreach ($arr as $k=>$v){
  $keysvalue[$k] = $v[$keys];
 }
 if($type == 'asc'){
  asort($keysvalue);
 }else{
  arsort($keysvalue);
 }
 reset($keysvalue);
 foreach ($keysvalue as $k=>$v){
  $new_array[$k] = $arr[$k];
 }
 return $new_array;
}
if($submitok == 'ajax_click'){
	if(ifint($fid)){
		$db->query("UPDATE ".__TBL_VIDEO__." SET click=click+1 WHERE id=".$fid);
	}
	echo  encode_json(array('flag'=>1));
	exit();

}elseif ($submitok == 'ajax_list'){
	$re=get_list($fid,$ids);
	echo  encode_json($re);
	exit();
}
if(ifint($fid)){
	$arrV=array();
	$rtV = $db->query("SELECT a.id,a.uid,a.path_s,a.agree,a.click,b.nickname,b.sex,b.grade,b.photo_s,b.photo_f,b.photo_ifshow,b.areatitle,b.heigh,b.edu,b.birthday FROM ".__TBL_VIDEO__." a,".__TBL_USER__." b WHERE a.uid=b.id AND a.flag=1 AND b.flag=1 AND a.id=".$fid);
	if($db->num_rows($rtV)){
		$rowV = $db->fetch_array($rtV,'name');
		$arrV['fid']     = $rowV['id'];
		$arrV['uid']     = $rowV['uid'];
		$arrV['poster']  = UP.smb($rowV['path_s'],'b');
		$arrV['agree']   = $rowV['agree'];
		$arrV['click']   = $rowV['click']+1;
		$arrV['video']   = UP.str_replace(".jpg",".mp4",$rowV['path_s']);
		$arrV['photo_s'] = (!empty($rowV['photo_s']) && $rowV['photo_f']==1)?UP.$rowV['photo_s']:RES.'photo_m'.$rowV['sex'].'.png';
		if($rowV['photo_ifshow']==0){$arrV['photo_s']=RES.'photo_m'.$rowV['sex'].'_hide.png';}
		$gzflag = ($db->COUNT(__TBL_GZ__,"flag=1 AND senduid=".$cook_uid." AND uid=".$rowV['uid']))?1:0;
		$arrV['gzflag']   = $gzflag;			
		if($gzflag==1){
			$arrV['gzcls']   = ' ed';
			$arrV['gzico']   = 'e6b1';
			$arrV['gzstr']   = '已关注';			
		}else{
			$arrV['gzcls']   = '';
			$arrV['gzico']   = 'e622';
			$arrV['gzstr']   = '关注';
		}			
		$arrV['sex'] = $rowV['sex'];
		$arrV['grade'] = $rowV['grade'];
		$arrV['nickname'] =trimhtml(dataIO($rowV['nickname'],'out'));
		$areatitle= $rowV['areatitle'];
		$birthday = $rowV['birthday'];
		$edu      = $rowV['edu'];
		$pay      = $rowV['pay'];
		$heigh    = $rowV['heigh'];		
		$aARR = explode(' ',$areatitle);$areatitle = $aARR[1].$aARR[2];
		$areatitle_str = (empty($areatitle))?'':$areatitle;
		$heigh_str     = (empty($heigh))?'':'<b>·</b>'.udata('heigh',$heigh);
		$edu_str       = (empty($edu))?'':'<b>·</b>'.udata('edu',$edu);
		$birthday_str  = (getage($birthday)<=0)?'':'<b>·</b>'.getage($birthday).'岁';
		
		$grade=substr($sexgrade,1,2);
		$sexgrade = (substr($sexgrade,0,1) == 0)?0:$sexgrade;			
		$arrV['video_uys']     = 'ugrade2';
		$arrV['video_uico']     = UP.'p/img/grade'.$arrV['sex'].$arrV['grade'].'.png?'.$_ZEAI['cache_str'];
		//
		$arrV['udata'] = $areatitle_str.$heigh_str.$edu_str.$birthday_str;
		$arrV['fzflag']     = 0;
		$arrV['videoid']     = $rowV['id'];			
		$arrV['videotitle']     = $arrV['udata'];
		$arrV['videousername']     = $arrV['nickname'];
		$arrV['videouserfilepath']     = $arrV['photo_s'];
		$arrV['viewzans']     = $arrV['agree'];
		$arrV['viewgifts']     = 0;
		$arrV['videoviews']     =$arrV['click']+1;  
		$arrV['videocomments']     = 0;
		//$arrV['size']     = array('w'=>,'h'=>)
		$arrV['size']=array();
		$db->query("UPDATE ".__TBL_VIDEO__." SET click=click+1 WHERE id=".$fid);
	}else{
		alert('亲，好像视频没找到',mHref('video'));
	}
}else{
	alert('亲，好像视频没找到',mHref('video'));
}
function get_list($fid,$ids='') {
	global $db,$cook_uid,$arrV;
	$zpage=20;
	$fid=intval($fid);
	$newarr=array();	
	$newids=array();
	$arr=array();	
	if(!empty($ids)){
		$newids=empty($ids)?array():explode(',',$ids);
		$ZEAI_SQL = "a.uid=b.id AND a.flag=1 AND b.flag=1 and !FIND_IN_SET(a.id,'$ids') ORDER BY a.id DESC limit ".$zpage;
	}else{
		$ZEAI_SQL = "a.uid=b.id AND a.flag=1 AND b.flag=1 and a.id<='$fid' ORDER BY a.id DESC limit ".$zpage;
		if(!empty($arrV)){
			$newarr[]=$arrV;
			$newids[]=$arrV['fid'];		
		}
	}
	$ZEAI_SELECT = "SELECT a.id,a.uid,a.path_s,a.agree,a.click,b.nickname,b.sex,b.grade,b.photo_s,b.photo_f,b.photo_ifshow,b.areatitle,b.heigh,b.edu,b.birthday FROM ".__TBL_VIDEO__." a,".__TBL_USER__." b WHERE ".$ZEAI_SQL;
	$rt    = $db->query($ZEAI_SELECT);
	$total = $db->num_rows($rt);		
	if ($total == 0) {
		return array('flag'=>0,'sid'=>0,'getstate'=>1);
	} else {			
		for($i=1;$i<=$total;$i++) {
			$tmprows = $db->fetch_array($rt,'name');
			if(!$tmprows) break;
			$arr['fid']     = $tmprows['id'];
			$arr['uid']     = $tmprows['uid'];
			$arr['poster']  = UP.smb($tmprows['path_s'],'b');
			$arr['agree']   = $tmprows['agree'];
			$arr['click']   = $tmprows['click'];
			$arr['video']   = UP.str_replace(".jpg",".mp4",$tmprows['path_s']);
			$arr['photo_s'] = (!empty($tmprows['photo_s']) && $tmprows['photo_f']==1)?UP.$tmprows['photo_s']:RES.'photo_m'.$tmprows['sex'].'.png';
			if($tmprows['photo_ifshow']==0){$arr['photo_s']=RES.'photo_m'.$tmprows['sex'].'_hide.png';}
			$gzflag = ($db->COUNT(__TBL_GZ__,"flag=1 AND senduid=".$cook_uid." AND uid=".$tmprows['uid']))?1:0;
			$arr['gzflag']   = $gzflag;			
			if($gzflag==1){
				$arr['gzcls']   = ' ed';
				$arr['gzico']   = 'e6b1';
				$arr['gzstr']   = '已关注';			
			}else{
				$arr['gzcls']   = '';
				$arr['gzico']   = 'e622';
				$arr['gzstr']   = '关注';
			}			
			$arr['sex'] = $tmprows['sex'];
			$arr['grade'] = $tmprows['grade'];
			$arr['nickname'] =trimhtml(dataIO($tmprows['nickname'],'out'));
			$areatitle= $tmprows['areatitle'];
			$birthday = $tmprows['birthday'];
			$edu      = $tmprows['edu'];
			$pay      = $tmprows['pay'];
			$heigh    = $tmprows['heigh'];		
			$aARR = explode(' ',$areatitle);$areatitle = $aARR[1].$aARR[2];
			$areatitle_str = (empty($areatitle))?'':$areatitle;
			$heigh_str     = (empty($heigh))?'':'<b>·</b>'.udata('heigh',$heigh);
			$edu_str       = (empty($edu))?'':'<b>·</b>'.udata('edu',$edu);
			$birthday_str  = (getage($birthday)<=0)?'':'<b>·</b>'.getage($birthday).'岁';
			
			$grade=substr($sexgrade,1,2);
			$sexgrade = (substr($sexgrade,0,1) == 0)?0:$sexgrade;			
			$arr['video_uys']     = 'ugrade2';
			$arr['video_uico']     = UP.'p/img/grade'.$arr['sex'].$arr['grade'].'.png?'.$_ZEAI['cache_str'];
			//
			$arr['udata'] = $areatitle_str.$heigh_str.$edu_str.$birthday_str;
			$arr['fzflag']     = 0;
			$arr['videoid']     = $tmprows['id'];			
			$arr['videotitle']     = $arr['udata'];
			$arr['videousername']     = $arr['nickname'];
			$arr['videouserfilepath']     = $arr['photo_s'];
			$arr['viewzans']     = $arr['agree'];
			$arr['viewgifts']     = 0;
			$arr['videoviews']     =$arr['click'];  
			$arr['videocomments']     = 0;
			//$arr['size']     = array('w'=>,'h'=>)
			$arr['size']=array();						
			$newarr[]=$arr;
			$newids[]=$tmprows['id'];
		}
	}
	if(@is_array($newarr) && @count($newarr)>0){		
		if($total>=$zpage){
			$getstate=0;
		}else{
			$getstate=1;
		}
		return array('flag'=>1,'list'=>$newarr,'videoids'=>implode(',',$newids),'getstate'=>$getstate);
	}else{
		return array('flag'=>0,'videoids'=>'','getstate'=>$getstate);
	}
}
$varr=get_list($fid,'');
if($varr['flag']==1){
	$sid=0;
	$vids = $varr['videoids'];
	$vlist = $varr['list'];
	$vinfo=$vlist[$sid];
	$vinfo['udata']=urldecode($vinfo['udata']);	
}else{
	alert('亲，好像视频没找到',mHref('video'));
	exit;
}
require_once ZEAI."api/weixin/jssdk.php";
?>
<!doctype html>
<html lang="en"><head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, minimum-scale=1.0, maximum-scale=1.0">
<title>小视频-<?php echo $_ZEAI['siteName'];?></title>
<link rel="stylesheet" type="text/css" href="<?php echo RES?>/video/css/base.css?<?php echo $_ZEAI['cache_str'];?>">
<link rel="stylesheet" type="text/css" href="<?php echo RES?>/video/css/swiper.min.css">
<link rel="stylesheet" type="text/css" href="<?php echo RES?>/video/css/shipin.css?<?php echo $_ZEAI['cache_str'];?>">
<link rel="stylesheet" type="text/css" href="<?php echo RES?>/video/css/animate.css?<?php echo $_ZEAI['cache_str'];?>">
<script src="<?php echo RES;?>www_zeai_cn.js?<?php echo $_ZEAI['cache_str'];?>"></script>
<script src="<?php echo RES;?>m/js/m.js?<?php echo $_ZEAI['cache_str'];?>"></script>
<script src="<?php echo RES?>video/js/jquery-1.11.0.min.js" type="text/javascript" charset="utf-8"></script>
<script src="<?php echo RES?>video/js/swiper.min.js" type="text/javascript" charset="utf-8"></script>
<script src="<?php echo RES?>video/js/common.js?<?php echo $_ZEAI['cache_str'];?>" type="text/javascript" charset="utf-8"></script>
<script src="//res.wx.qq.com/open/js/jweixin-1.3.2.js"></script>
<script>
    var t="<?php echo $signPackage["timestamp"];?>",n="<?php echo $signPackage["nonceStr"];?>";
    var obj = {
        current: -1,
        videoids: "<?php echo $vids?>",
        state: "0",
        webcode:"",
        memberid:0,
        videoData:<?php echo encode_json($vlist);?>,  
        oneData: {
            poster: "",
            video: ''
        },
        twoData: {
            poster: "",
            video: ''
        },
        threeData: {
            poster: "",
            video: ''
        }
    }
    var mobanurl = "<?php echo HOST;?>/m/video_detail.php",domainurl="<?php echo HOST;?>",
       title = "会员小视频相亲展示", desc = "展示美好自己，从今天开始我就是我...",rcmd_url="<?php echo HOST;?>/m/video.php",
       img_url = "",
       callback_url = "";
	wx.config({debug:false,
		appId: '<?php echo $signPackage["appId"];?>',
		timestamp: parseInt(t),
		nonceStr: n,
		signature: '<?php echo $signPackage["signature"];?>',
		jsApiList: ['hideMenuItems','onMenuShareTimeline','onMenuShareAppMessage','onMenuShareQQ','onMenuShareWeibo']

	});
    function WeChat(){
        wx.ready(function () {
            wx.miniProgram.postMessage({ data:{title:title,rcmd_url:rcmd_url,img_url:img_url,callback_url:callback_url} });
            wx.showOptionMenu();
            wx.onMenuShareTimeline({
                title: title,
                link: rcmd_url,
                imgUrl: img_url,
                success: function (res) {
                    $('#share-box').hide();
                    //$.post(callback_url, {}, function () { }, "json");
                },
                cancel: function (res) {
                    return;
                },
                fail: function (res) {

                }
            });
            wx.onMenuShareAppMessage({
                title: title,
                desc: desc,
                link: rcmd_url,
                imgUrl: img_url,
                success: function () {
                    $('#share-box').hide();
                    //$.post(callback_url, {}, function () { }, "json");
                },
                cancel: function () {
                    return;
                },
                fail: function (res) {

                }
            });
        });
    }
    $(function(){ 
        var hidden = "hidden";
        if (hidden in document)
            document.addEventListener("visibilitychange", pageonchange);
        else if ((hidden = "mozHidden") in document)
            document.addEventListener("mozvisibilitychange", pageonchange);
        else if ((hidden = "webkitHidden") in document)
            document.addEventListener("webkitvisibilitychange", pageonchange);
        else if ((hidden = "msHidden") in document)
            document.addEventListener("msvisibilitychange", pageonchange);
        else if ("onfocusin" in document)
            document.onfocusin = document.onfocusout = pageonchange;
        else
            window.onpageshow = window.onpagehide = window.onfocus = window.onblur = pageonchange;
        var u = navigator.userAgent,app = navigator.appVersion;
        var isAndroids = u.indexOf('Android') > -1 || u.indexOf('Linux') > -1; //g	
        function pageonchange(evt) {
            if (document[hidden]) {
                if (isAndroids) {
                    $('#player')[0].pause();
                } else {
                    $('#my-video')[0].pause();
                }
            } 
            else{
                setTimeout(function () {
                    if (isAndroids) {
                        $('#player')[0].play();
                    } else {
                        $('#my-video')[0].play();
                    }
                },100);
            }
        }
        if (document[hidden] !== undefined){
            pageonchange({
                type: document[hidden] ? "blur" : "focus"
            });
        }        
    })
</script> 
</head>
<body>
<video onclick="goPlay(event)" poster="<?php echo $vinfo['poster'];?>" id="player" src="<?php echo $vinfo['video'];?>" webkit-playsinline="true" x5-playsinline="true" playsinline="" loop x5-video-player-type="h5" preload="auto" style="width: 100%; height: 100%; background: rgb(0, 0, 0); object-fit: contain; position: absolute; display: none; z-index: 0;" autoplay>
  <h5>您的系统不支持Video标签</h5>
</video>
<input type="hidden" id="videoid" value="<?php echo $vinfo['videoid'];?>">
<div class="swiper-container video_banner swiper-container-initialized swiper-container-vertical swiper-container-ios" id="shipin_banner_box">
  <div class="swiper-wrapper" style="transform: translate3d(0px, -100vh, 0px); transition-duration: 0ms;">
    <div class="swiper-slide swiper-slide-prev" style="height:100vh;">
      <div class="posterImg" id="PrevEle"></div>
    </div>
    <div class="swiper-slide swiper-slide-active" style="height:100vh;">
      <!--组件-->
      <div class="btn-play-opacity" onclick="goPlay(event)"></div>
      <div onclick="goPlay(event)" class="play_btn" style="display: none;"></div>
      <video id="my-video" onclick="goPlay(event)" class="video_ele" poster="<?php echo $vinfo['poster'];?>" src="<?php echo $vinfo['video'];?>" preload="auto" webkit-playsinline="true" x5-playsinline="true" playsinline="" loop x5-video-player-type="h5" x5-video-player-fullscreen="true" autoplay style="object-fit: cover;">
        <p class="vjs-no-js"> 要查看此视频，请启用升级到 <a href="http://videojs.com/html5-video-support/" target="_blank">最新版本h5视频</a> </p>
      </video>

      <div class="video_buttom_info">
        <div class="bottom_content">
          <div class="header_banner header_pic_btn <?php echo ($vinfo['gzflag']==1)?' active':''?>" uid="<?php echo $vinfo['uid'];?>">
            <div class="img_banner"><img src="<?php echo $vinfo['videouserfilepath'];?>"> </div>
            <div class="guanzhu_icon animated"> </div>
          </div>
          <div class="dianzan_banner  dianzan_btn">
            <div class="dianzan_icon animated"><em class="ico">&#xe652;</em></div>
            <div class="txt"><?php echo $vinfo['viewzans'];?></div>
          </div>
          <div class="pinglun_banner pinglin_btn">
            <div class="pinglun_icon"><em class="ico">&#xe643;</em></div>
            <div class="txt"><?php echo $vinfo['videoviews'];?></div>
          </div>                
        </div>
      </div>

      <div class="music_box_banner active" id="music_btn">
        <div class="music_hei ">
          <div class="img_banner"> <img src="<?php echo $vinfo['videouserfilepath'];?>"> </div>
        </div>
        <i class="iconbbs iconbbs-music"></i> <i class="iconbbs iconbbs-music1"></i> </div>


    </div>
    <div class="swiper-slide swiper-slide-next" style="height:100vh;">
      <div class="posterImg" id="NextEle" style="background-image: url(<?php echo $vlist[1]['poster'];?>);"></div>
    </div>
  </div>
<span class="swiper-notification" aria-live="assertive" aria-atomic="true"></span></div>
<a class="back" onClick="zeai.back();"><em class="ico S24">&#xe602;</em></a>
<!--页脚开始-->
<ul class="tab-nav-bottom" id="nav_btn" uid="">
<li class="tab-nav-bottom-item utitle"><img class="<?php echo $vinfo['video_uys'];?>" src="<?php echo $vinfo['video_uico'];?>"><?php echo $vinfo['videousername'];?></li><li class="tab-nav-bottom-item content"><?php echo $vinfo['videousername']?></li>
</ul>
<!--页脚结束-->
<!--分享开始-->
<div class="share_bg displayfalse" id="share_bg_btn"></div>
<!--分享结束-->
<style>.iphonex.tab-nav-bottom,.pinglun_alert_banner{padding-bottom:20px;}.iphonex.fabuNeirong_container {bottom:80px;}</style>
<script>	
	$(function(){
		$("#nav_btn").on("click",function(){
			var uid=$(this).attr("uid");
			window.location.href='<?php echo HOST;?>/m/u.php?uid='+uid;		
		});	
	});
    var width = window.screen.width * window.devicePixelRatio
    var height = window.screen.height * window.devicePixelRatio
    if (  ( (height == 2436 && width == 1125) || (height == 1792 && width == 828))   && $(window).height()>641) {
        $(".tab-nav-bottom,.fabuNeirong_container").addClass('iphonex');
        $(".pinglun_alert_banner").addClass('iphonex');
    }
</script>
<script src="<?php echo RES?>video/js/videodetails.js?<?php echo $_ZEAI['cache_str'];?>" type="text/javascript" charset="utf-8"></script>
<script>
    $(function(){
        window.addEventListener("pagehide", function () {
            if (isAndroid) {
                $('#player')[0].stop();
            } else {
                $('#my-video')[0].stop();
            }
        });
    })
</script>
</body></html>